import { Repository } from 'typeorm';
import { InjectRepository } from '@nestjs/typeorm';
import { TTiktok } from 'src/entities/tiktok.entity';

export class TiktokRepository {
  constructor(
    @InjectRepository(TTiktok)
    private tiktokRepository: Repository<TTiktok>,
  ) {}

  //   查询tiktok列表
  async queryTiktokListRepository() {
    return this.tiktokRepository.find({
      where: {
        delFlag: 0,
      },
    });
  }

  //   增加
  async addTiktokRepository(params: any) {
    const tiktok = this.tiktokRepository.create(params);
    return this.tiktokRepository.save(tiktok);
  }

  //   删除
  async deleteTiktokRepository(id: number) {
    return this.tiktokRepository.update(id, { delFlag: 1 });
  }

  //   修改
  async updateTiktokRepository(id: number, params: any) {
    return this.tiktokRepository.update(id, params);
  }
}
